/**
 * Created by oneminute on 7/17/14.
 */

var lz = require("../lib/utils/modules")();

exports.get = function (_req, _res, _opts, _callback) {
    var user = _req.user;
    var did = _req.query.nid;
    if (!user) {
        lz.Logger.warn("/delgoods: 用户为临时用户。");
        _callback(lz.Config.errors.getError(lz.Config.errors.REQUEST_TEMPUSER_ERROR));
        return;
    }
    user.deleteDemand(did, function (_err, _user) {
        if (_err) {
            lz.Logger.error("/delgoods: 删除需求出现错误。");
            _callback(_err, user);
        } else {
            _callback(null, user);
        }
    });
};